#include "objToIsm1.h"
#include "xToSam1.h"
#include "objsToKam1.h"
using namespace std;
enum FILE_EXT
{ 
	FILE_EXT_ERROR = -1,
	OBJ = 0,
	ISM1, // indices static mesh
	X,// directX .x file format
	SAM1,// skinning animated mesh
	KAM1,// keyframing animated mesh
};
FILE_EXT getFileExt(char *filename)
{
	vector<string> files;
	split(string(filename),files,';');
	vector<string> part;
	split(files[0],part,'.');
	string extStr = part[ part.size()-1];
	if(!extStr.compare("obj"))
		return OBJ;
	else if(!extStr.compare("ism1"))
		return ISM1;
	else if(!extStr.compare("x"))
		return X;
	else if(!extStr.compare("sam1"))
		return SAM1;
	else if(!extStr.compare("kam1"))
		return KAM1;
	return FILE_EXT_ERROR;
}
int main(int argc, char **argv )
{
	if( argc<3)
	{
		cout<<"\nMust have input and output filename!";
		return 0;
	}
	FILE_EXT type1 = getFileExt(argv[1]);
	FILE_EXT type2 = getFileExt(argv[2]);
	if(type1==OBJ&&type2==ISM1)
	{
		char *option = 0;
		if( argc>3) //Get option
		{
			option = argv[3];
		}
		objToIsm1(argv[1],argv[2],option);
	}
	/*if(type1==X&&type2==SAM1)
		xToSam1(argv[1],argv[2]);*/

	if(type1==OBJ&&type2==KAM1)
	{
		char *option = 0;
		if( argc>4) //Get option
		{
			option = argv[4];
		}
		objsToKam1(argv[1],argv[2],argv[3],option);
	}
    system("PAUSE");
	return 1;
}